import request from '@/utils/request'
// 题库管理

// 获取基础题库列表
export const getQuestions = params => {
  return request({
    method: 'GET',
    url: '/questions',
    params
  })
}

// 获取学科列表
export const getSubjects = params => {
  return request({
    method: 'GET',
    url: '/subjects',
    params
  })
}

// 获取精选题库
export const getQuestionsChoice = params => {
  return request({
    method: 'GET',
    url: '/questions/choice',
    params
  })
}

// 获取二级目录
export const getDirectorys = params => {
  return request({
    method: 'GET',
    url: '/directorys',
    params
  })
}
// 获取标签
export const getTags = params => {
  return request({
    method: 'GET',
    url: '/tags',
    params
  })
}
// 获取企业数据
export const getCompanys = params => {
  return request({
    method: 'GET',
    url: '/companys',
    params
  })
}

// 获取组题列表
export const getRandoms = params => {
  return request({
    method: 'GET',
    url: '/questions/randoms/',
    params
  })
}

// 添加题库
export const addRandoms = data => {
  console.log(data)

  return request({
    method: 'POST',
    url: '/questions',
    data
  })
}

// 基础题库详情
export const getQuestionsPart = id => {
  return request({
    method: 'GET',
    url: `/questions/${id}`
    // params: { id }
  })
}

// 删除题目
export const delQuestion = id => {
  return request({
    method: 'DELETE',
    url: `/questions/${id}`
  })
}

// 加入或移出精选题库
export const ADchoiceQuestions = (id, choiceState) => {
  return request({
    method: 'PATCH',
    url: `/questions/choice/${id}/${choiceState}`
  })
}
// 试题审核
export const auditQuestions = (id, data) => {
  return request({
    method: 'POST',
    url: `/questions/check/${id}`,
    data
  })
}
// 上架或下架题库
export const editPublishState = (id, publishState) => {
  return request({
    method: 'POST',
    url: `/questions/choice/${id}/${publishState}`
  })
}
